<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3" xmlns:head="http://www.w3.org/1999/html">
<head th:include="public/public_css::public_css ('库存冻结')"/>

<body style="background-color: #f2f2f2;">
<div class="layui-fluid larry-wrapper">
    <div class="layui-card">
        <div class="layui-row layui-col-space30">
            <div class="layui-col-xs24">

                <form class="layui-form layui-card-header  layui-card-header-auto" id="searchForm">

                    <div class="layui-inline">
                        <label class="layui-form-label">冻结人</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="cjry"/>
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label">解冻人</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="jdry"/>
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label">冻结单号</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="djdh"/>
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label">冻结状态</label>
                        <select name="zt" lay-filter="aihao">
                            <option value="" selected="">全部</option>
                            <option value="0">全部冻结</option>
                            <option value="1">部分冻结</option>
                            <option value="2">全部解冻</option>
                        </select>
                    </div>


                    <div class="layui-inline inline-search-btn">
                        <a class="layui-btn layui-btn-normal search_btn" lay-event="searchEvent" data-type="reload">查询</a>
                    </div>
                    <div class="moreSearch" style="display: none">

                        <!--<div class="layui-inline">
                            <label class="layui-form-label">创建时间</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="stime" id="stime"
                                       placeholder="yyyy-MM-dd"/>
                            </div>
                        </div>-->
                        <div class="layui-inline">
                            <label class="layui-form-label">创建时间开始</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="stime" id="stime"
                                       placeholder="yyyy-MM-dd"/>
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label"> </label>
                            <div class="layui-input-inline" style="height:20px">
                                --
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">创建结束时间</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="etime" id="etime" placeholder="yyyy-MM-dd"/>
                            </div>
                        </div>

                        <!--<div class="layui-inline">
                            <label class="layui-form-label">解冻时间</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="jdtime" id="jdtime"
                                       placeholder="yyyy-MM-dd"/>
                            </div>
                        </div>-->

                        <div class="layui-inline">
                            <label class="layui-form-label">解冻时间开始</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="jdtime" id="jdtime"
                                       placeholder="yyyy-MM-dd"/>
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label"> </label>
                            <div class="layui-input-inline" style="height:20px">
                                --
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">解冻结束时间</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="jdetime" id="jdetime" placeholder="yyyy-MM-dd"/>
                            </div>
                        </div>
                    </div>
                    <!--<div class="layui-inline inline-reset-btn">
                        <button type="reset" class="layui-btn layui-btn-normal">重置</button>
                    </div>-->
                </form>

                <div class="moreBtn"><i class="layui-icon layui-icon-triangle-d" style="color: #1E9FFF;"></i></div>

                <div class="group-button tpl-button" id="toolbar">
                </div>
                <!--列表-->
                <section class="panel panel-padding layui-card-body">
                    <div class="pro">
                        <table id="table"></table>
                    </div>
                </section>

            </div>
        </div>
    </div>
</div>

</body>


<div th:include="public/public_js::public_js"></div>
<div th:include="public/public_btn::public_btn"></div>
<style type="text/css">
    .moreBtn {
        width: 50px;
        height: 20px;
        text-align: center;
        color: #fff;
        line-height: 20px;
        background-color: #eee;
        position: relative;
        margin: 0 auto;
        cursor: pointer;
    }

    .moreBtn:before {
        content: '';
        display: block;
        width: 35px;
        height: 20px;
        position: absolute;
        transform: skewX(30deg);
        background: #eee;
        border-top-left-radius: 8px;
        left: -20px;
        top: 0;
    }

    .moreBtn:after {
        content: '';
        display: block;
        width: 35px;
        height: 20px;
        position: absolute;
        transform: skewX(-30deg);
        background: #eee;
        border-top-right-radius: 8px;
        top: 0;
        right: -20px;
    }
</style>
<script th:inline="javascript">
    $(function () {
        $(".moreBtn").on("click", function () {
            $(".moreSearch").toggle();
        });
        $(document).ready(function () {//通用方法去输入框前后空格
            $("form").on("change", function () {
                $("form input[type=text]").each(function () {
                    this.value = $.trim(this.value);
                });
            })
        });
    });

    var functions = [[${functions}]];
    layui.use(['list', 'layer', 'zzpUtils', 'jquery', 'laydate', 'tablebutton'], function () {



        var zzpUtils = layui.zzpUtils,
            $ = layui.jquery,
            laydate = layui.laydate,
            tablebtn = layui.tablebutton;
        var $table;
        tablebtn.buildOnClick({
            type: 1,
            temp: $("#function_tpl"),
            functions: functions.headBtn,
            row: null,
            event: {
                searchEvent: function(){
                    zzpUtils.refreshTable("#table");
                },
                addEvent: function (data) {
                    add();
                },
                Stockthawing: function (data) {
                    editDialog(data.row.id);
                },
                exportEvent: function(data){
                    if (data.row != undefined) {
                        var ids = [];
                        ids.push(data.row.id);
                        /*
                        * 以下是将ids和对象拼接在一起
                        * */
                        var str=zzpUtils.getFormJson($("#searchForm"));
                        var object2 = Object.assign({ids: ids}, str);
                        /*将条件查询和ids传到后台*/
                        zzpUtils.outputXslx({
                            url:"/wmsstockfrozen/exportWmsStockFrozen",
                            data:JSON.stringify(object2)
                        });

                    } else {
                        var arr=[];
                        var $rows = $table.bootstrapTable('getSelections');
                        if ($rows.length >0) {
                            arr = $.map($rows, function (row) {
                                return row.id;
                            })
                        }
                        /*
                         * 以下是将ids和对象拼接在一起
                         * */
                        var str=zzpUtils.getFormJson($("#searchForm"));
                        var object2 = Object.assign({ids: arr}, str);
                        /*将条件查询和ids传到后台*/
                        zzpUtils.outputXslx({
                            url:"/wmsstockfrozen/exportWmsStockFrozen",
                            data:JSON.stringify(object2)
                        });

                    }
                }
            }
        });
        function add() {
            zzpUtils.dialog({
                title: "新增库存冻结",
                type: 2,
                content: "/Stock/Inventory",
                area: ['90%', '90%'], //设置dialog大小，也可以不设置，
                end: function () {//增加成功后刷新
                    zzpUtils.refreshTable("#table");
                }
            });
        }

        //解冻库存
        function editDialog(id) {
            zzpUtils.dialog({
                title: "解冻库存",
                type: 2,
                content: "/Stock/Thawing?id=" + id,
                area: ['90%', '90%'], //设置dialog大小，也可以不设置，
                end: function () {//修改成功后刷新
                    zzpUtils.refreshTable("#table");
                }
            });
        }

        /*//创建时间开始
        laydate.render({
            elem: '#stime'
            , theme: '#20a0ff'
            , range: '~'//练起来
        });

        //解冻开始时间
        laydate.render({
            elem: '#jdtime'
            , theme: '#20a0ff'
            , range: '~'//练起来
        })*/
        //创建时间开始
        laydate.render({
            elem: '#stime'
            , theme: '#20a0ff',
        });
        //创建时间结束
        laydate.render({
            elem: '#etime'
            , theme: '#20a0ff',
        });
        //创建时间开始
        laydate.render({
            elem: '#jdtime'
            , theme: '#20a0ff',
        });
        //创建时间结束
        laydate.render({
            elem: '#jdetime'
            , theme: '#20a0ff',
        });

        var $table = zzpUtils.table({
            elem: '#table',
            isApi: true,
            isOperate: true,
            pagination: true,
            url: '/wmsstockfrozen/list',
            columns: [{
                field: '',
                checkbox: true
            }, {
                field: 'djdh',
                title: '冻结单号'
            }, {
                field: 'cjsj',
                title: '创建时间',
                formatter: function (value, row, index) {
                    var sj='';
                    if(value!=null&&value!=''){
                        sj=value.substring(0,19);
                    }
                    return sj;
                }
            }, {
                field: 'jdsj',
                title: '解冻时间',
                formatter: function (value, row, index) {
                    var sj='';
                    if(value!=null&&value!=''){
                        sj=value.substring(0,19);
                    }
                    return sj;
                }
            }, {
                field: 'cjry',
                title: '冻结人'
            }, {
                field: 'jdry',
                title: '解冻人'
            }, {
                field: 'show_zt',
                title: '冻结状态'
            }/*,{
                field: 'caozuo',
                title: '操作',
                events: operateEvent,
                formatter: operateFormatter
            }*/],
            queryParams: function () {//查询条件
                return zzpUtils.getFormJson($("#searchForm"));
            },
            detailFormatter: function (index, row) {
                return "这里就没有确定过11";
            },
            /*定义表格右侧按钮*/
            operateFormatter: operateFormatter
        });

        /*表格右侧按钮*/
        function operateFormatter(value, row, index) {
            var  button = '', buttons1 = '', buttons2 = '';
            for (var i = 0; i < functions.tableBtn.length; i++) {
                var item = functions.tableBtn[i];
                var btn = '<a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="' + functions.tableBtn[i].event + '">'
                    + functions.tableBtn[i].name
                    + '</a>';
                if (row.zt == '0') {//全部冻结
                    if (functions.tableBtn[i].name == '解冻' || functions.tableBtn[i].name == '导出') {
                        buttons1 += btn;
                    }
                } else if (row.zt=='1') {//部分冻结
                    if (functions.tableBtn[i].name == '解冻' || functions.tableBtn[i].name == '导出') {
                        buttons1 += btn;
                    }
                } else if (row.zt=='2') {//导出
                    if (functions.tableBtn[i].name == '导出') {
                        buttons1 += btn;
                    }
                }
            }

            return buttons1;
        }


        /*表格右侧按钮*/
        /*function operateFormatter(value, row, index) {
            if (row.zt == 0) {//冻结
                return [
                    '<a class="layui-btn layui-btn-xs" id="btn_qr">解冻</a>',
                    /!*'<a class="layui-btn layui-btn-danger layui-btn-xs" id="btn_dc">导出</a>'*!/
                ].join('')
            } else if(row.zt==1) {//部分冻结
                return [
                    '<a class="layui-btn layui-btn-xs" id="btn_qr">解冻</a>',
                   /!* '<a class="layui-btn layui-btn-danger layui-btn-xs" id="btn_dc">导出</a>'*!/
                ].join('')
            }/!*else if(row.zt==2){//全部解冻（导出）
                return [
                    '<a class="layui-btn layui-btn-danger layui-btn-xs" id="btn_dc">导出</a>'
                ].join('')
            }*!/
        }*/

       /* //查询
        $(".inline-search-btn").on('click', function () {
            zzpUtils.refreshTable("#table");
        })
*/



    });

</script>
</html>